import { defineComponent } from 'vue'
import type { NavigationGuard } from 'vue-router'

export type Component<T = unknown> =
    | ReturnType<typeof defineComponent>
    // | (() => Promise<typeof import('*.vue')>)
    | (() => Promise<T>)

export interface AppRouteMeta {
    roles?: string[] // 配置能访问该页面的角色，如果不匹配，则会被禁止访问该路由页面
    requiresAuth: boolean // 是否需要登录鉴权
    icon?: string // 菜单配置icon
    locale?: string // 一级菜单名（语言包键名）
    hideInMenu?: boolean // 是否在左侧菜单中隐藏该项
    hideChildrenInMenu?: boolean // 强制在左侧菜单中显示单项
    activeMenu?: string // 高亮设置的菜单项
    order?: number // 排序路由菜单项。如果设置该值，值越高，越靠前
    ignoreCache?: boolean // 如果设置为true页面将不会被缓存
}

export interface AppRouteRecordRaw {
    path: string
    name?: string | symbol
    meta?: AppRouteMeta
    redirect?: string
    component: Component | string
    children?: AppRouteRecordRaw[]
    alias?: string | string[]
    props?: Record<string, unknown>
    beforeEnter?: NavigationGuard | NavigationGuard[]
    fullPath?: string
}
